/* Copyright 2008 Bas van den Berg
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef MUDMOBILE_H
#define MUDMOBILE_H

#include "MudObject.h"
#include "Stats.h"

namespace Chronos {

class MudMobile : public MudObject, public MudObjectListener {
public:
    MudMobile(const std::string& name_, const std::string& descr_, int maxHealth_, int speed_, int maxDamage_, int hitChance_);
    MudMobile(const std::string& name_, const std::string& descr_, const Stats& stats_);
    MudMobile(const MudMobile& rhs);
    virtual ~MudMobile();
    virtual void accept(CmdVisitor& v);

    virtual bool handleObjectEvent(MudObject&, MudObjectEvent event);

    virtual void write(const std::string&); // SMELL!!

    virtual void addTarget(MudMobile& target);
    virtual unsigned int doCombat() = 0;
    virtual void miss(MudMobile& source) = 0;

	// NOTE: after taking dmg a mudmobile object might cease to
	// exist, so callers cannot do any other calls on it.
    virtual bool takeDmg(MudMobile& source, unsigned int dmg) = 0;

    bool isInCombat() const;
    const Stats& getStats() const;

    int getHealth() const;
    int getMaxHealth() const;
    void heal(unsigned int hp);
protected:
    void die(const std::string& cause);
	virtual void createCorpse(const std::string& cause);

    Stats stats;
    bool inCombat;

    MudMobile* combatTarget;
private:
    MudMobile& operator=(const MudMobile&);
};

}

#endif

